<template>
  <el-dropdown trigger="click">
    <div>
      <svg-icon style="color: #fff" icon-class="language" />
    </div>
    <template>
      <el-dropdown-menu>
        <el-dropdown-item
          :disabled="$i18n.locale === 'zh'"
          @click.native="changeLang('zh')"
        >中文</el-dropdown-item>
        <el-dropdown-item
          :disabled="$i18n.locale === 'en'"
          @click.native="changeLang('en')"
        >en</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>
<script>
import jsCookie from 'js-cookie'
export default {
  name: 'Lang',
  methods: {
    changeLang(str) {
      this.$i18n.locale = str
      // this.$router.back()====this.$router.go(-1)
      // this.$router.go(1)  前进
      // this.$router.go(0)  刷新
      // this.$router.go(-1) 后退
      this.$router.go(0)
      jsCookie.set('lang', str)
    }
  }
}
</script>
<style></style>
